package ru.reaperoq.taskmanager.services

import org.springframework.security.core.userdetails.UserDetails
import org.springframework.security.core.userdetails.UserDetailsService
import org.springframework.stereotype.Service
import ru.reaperoq.taskmanager.repositories.UserRepository

@Service
class MyUserDetailsService(
    private val userRepository: UserRepository
) : UserDetailsService {

    override fun loadUserByUsername(username: String?): UserDetails =
        userRepository.findUserByUsername(username!!) ?: throw RuntimeException("User not found")
}